Building Conditional Expressions

Some functions allow multiple results based on conditions, such as the If and Where() functions.  The condition is any conditional expression that evaluates to boolean values (True or False).  This can be a simple field containing boolean values, a function that returns a boolean value, a comparison between two values, or even multiple conditions that resolve to a single boolean result.

The most common format is Value1 operator Value2 which compares one value to another, although more complex comparisons are possible.  The Value1 and Value2 data can include placeholders, formulas, or even other functions (including other conditional functions).

The operators and other options are detailed below.

Operators

The operator determines what comparison will be made between the values.

=

Checks if the two values are exactly equal.

<

Checks if the first value is less than the second value.

>

Checks if the first value is greater than the second value.

<=

Checks if the first value is less than or equal to the second value.

>=

Checks if the first value is greater than or equal to the second value.

<>

Checks if the two values are not exactly equal.  This can also be achieved using the Not option detailed below.

Examples:  

If Sum([[GridColumn]]) > [[Tolerance]] then TrueValue else FalseValue endif

Uses the Sum() function to determine the total of all values in a grid column, and checks if it is greater than a maximum value found in the [[Tolerance]] field.

If [[RenewalDate]] <= TodayXml() then TrueValue else FalseValue endif

Retrieves the value of the [[RenewalDate]] field and checks if it is less than or equal to today's date, retrieved by the TodayXml() function.

Negative Conditions

Starting the function with If not will check that the conditions are not met.  If the conditions evaluate as false, then the TrueValue is returned, else the FalseValue is returned.  While using different operators can often achieve the same results, using Not may simplify complex conditions.

This can also be used with the Where() function, by adding it to the beginning of the conditions, such as Where(Not Value1 operator Value2).

Examples:  

If 5 < 3 then TrueValue else FalseValue endif returns the FalseValue because we are checking that the first value is less than the second.

If not 5 < 3 then TrueValue else FalseValue endif returns the TrueValue because we are checking that the first value is not less than the second.

Combined Conditions

Multiple conditions can be checked within a single expression.  Placing multiple Value1 operator Value2 sets, separated by and or or, will evaluate each set individually, then evaluate the and conditions followed by the or conditions.

Example:  

If 5 < 3 and 8 > 4 or 9 = 9 and 4 > 2 then TrueValue else FalseValue endif

The individual conditions are evaluated first, producing the following results.

If false and true or true and true then TrueValue else FalseValue endif

The and conditions are evaluated next. An and evaluates to true if both conditions are true, producing the following results.

If false or true then TrueValue else FalseValue endif

The or conditions are evaluated next. An or evaluates to true if either condition is true, producing the following results

If true then TrueValue else FalseValue endif

The final result is true, so the function returns the TrueValue.

In situations where an or condition must be evaluated before an and condition, brackets () can be used to divide entire sections.  The contents of the innermost brackets will be completely evaluated first, then the next brackets out, and so on.

Example:  

If (5 < 3 and (8 > 4 or 9 = 8)) and 4 > 2 then TrueValue else FalseValue endif

The individual conditions are evaluated first, producing the following results.

If (false and (true or false)) and true then TrueValue else FalseValue endif

The (true or false) is evaluated first. Being an or, it evaluates as true.

If (false and true) and true then TrueValue else FalseValue endif

The (false and true) is evaluated next. Being an and, it evaluates as false.

If false and true then TrueValue else FalseValue endif

The remaining and condition is evaluated, producing in a false result, and the function returns the FalseValue.

Working with Boolean Values

Triggers and certain functions validate one or more conditions and return either "True" or "False", known as boolean values.  These can be used in a variety of ways.

  • When evaluating conditions in a trigger, If statement, or Where() function, the system retrieves the data to be checked and compares it to the condition value to determine if the statement is true or false.
  • If the data to be checked is either a boolean function or a field with a saved boolean value, the condition value can be left out.  The system will accept the data as the result.

    For example, the two following If statements will work exactly the same:

    If BooleanFunction() = "True" then TrueValue else FalseValue endif

    If BooleanFunction() then TrueValue else FalseValue endif

    As will the two following Where() calculations:

    Sum(Value) Where(BooleanFunction = "True")

    Sum(Value) Where(BooleanFunction)

  • The Checkbox field type stores a boolean value, and can be used without condition values as described above.
  • By default, boolean functions return "True" or "False", which will be shown if the results are displayed in the workflow.  However, "1" and "Yes" are also recognized as "True", while "0" and "No" are also recognized as "False". These alternate values are mainly supported for compatibility with older calculations, but may be used if necessary. Boolean values are not case-sensitive.
  • A null value evaluates to "False" in boolean expressions. If a field used in a boolean expression evaluates to null, and that field is then used in comparison to another specified value through an If statement or Where() function, the following rules are respected depending on the value of the comparison field.
Value of Comparison Field Boolean Result Notes
'' True Two single quotation marks.
Null / null True  
False / false True  
No / no True  
0 True  
'0' True  
Empty True The field is empty, or blank.
'No' / 'no' False  
'False' / 'false' False  
1 False  

'Null' / 'null'

False